﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsForms.AOnline.View.Dictionary;

namespace WindowsForms.AOnline.Presenter.Dictionary.AutoNumber
{
    public class AutoNumberPresenter : Presenter<IAutoNumberView>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AutoNumberPresenter"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        public AutoNumberPresenter(IAutoNumberView view)
            : base(view)
        {
        }

        /// <summary>
        /// Displays the type of the by reference.
        /// </summary>
        /// <param name="refType">Type of the reference.</param>
        public void DisplayByRefType(int refType)
        {
            if (refType == 0) return;

            var autoId = Model.GetAutoNumberByRefType(refType);
            if (autoId == null) return;
            View.Prefix = autoId.Prefix;
            View.Value = autoId.Value;
            View.LengthOfValue = autoId.LengthOfValue;
            View.Suffix = autoId.Suffix;
        }
    }
}
